home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume10 / pccurses14 / part03 < prev    next >
Encoding:
Text File  |  1990-01-19  |  46.5 KB  |  1,476 lines

  1. Newsgroups: comp.sources.misc
  2. subject: v10i017: PCcurses v.1.4 part 3 of 7
  3. from: bl@infovox.se (Bj|rn Larsson)
  4. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5.  
  6. Posting-number: Volume 10, Issue 17
  7. Submitted-by: bl@infovox.se (Bj|rn Larsson)
  8. Archive-name: pccurses14/part03
  9.  
  10. # ----------------------------- cut here -----------------------------
  11. #! /bin/sh
  12. # This is a shell archive. Remove anything before the `cut' line,
  13. # then unpack by saving it into a file and typing `sh file'. The
  14. # archive ends by exit(0), so don't worry about trailing junk.
  15. #       (This is archive 3 in a series of 7).
  16. # Contents:
  17. #   charadd.c
  18. #   charins.c
  19. #   curses68.c
  20. #   make.man
  21. #   newwin.c
  22. #   overlay.c
  23. #   strget.c
  24. # Wrapped by USER@MS-DOS --- Sun Jan 14 14:02:33 1990
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f charadd.c -a "${1}" != "-c" ; then 
  27.   echo Will not over-write existing file \"charadd.c\"
  28. else
  29. echo Extracting - \"charadd.c\"
  30. sed "s/^X//" >charadd.c <<'END_OF_charadd.c'
  31. X/****************************************************************/
  32. X/* Addch() routines of the PCcurses package            */
  33. X/*                                */
  34. X/****************************************************************/
  35. X/* This version of curses is based on ncurses, a curses version    */
  36. X/* originally written by Pavel Curtis at Cornell University.    */
  37. X/* I have made substantial changes to make it run on IBM PC's,    */
  38. X/* and therefore consider myself free to make it public domain.    */
  39. X/*                Bjorn Larsson (bl@infovox.se)    */
  40. X/****************************************************************/
  41. X/* 1.4:  Use short wherever possible. Portability        */
  42. X/*     improvements:                    900114    */
  43. X/* 1.3:     MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  44. X/* 1.2:     Max limits off by 1. Fixed thanks to S. Creps:    881002    */
  45. X/* 1.1:     Added 'raw' output routines (allows PC charac-        */
  46. X/*     ters < 0x20 to be displayed:            880306    */
  47. X/* 1.0:     Release:                    870515    */
  48. X/****************************************************************/
  49. X
  50. X#include <curses.h>
  51. X#include <curspriv.h>
  52. X
  53. Xchar _curses_charadd_rcsid[] = "@(#)charadd.c    v.1.4  - 900114";
  54. X
  55. X/****************************************************************/
  56. X/* Newline() does line advance and returns the new cursor line.    */
  57. X/* If error, return -1.                        */
  58. X/****************************************************************/
  59. X
  60. Xstatic    short    newline(win, lin)
  61. X  WINDOW    *win;
  62. X  short      lin;
  63. X  {
  64. X  if (++lin > win->_regbottom)
  65. X    {
  66. X    lin--;
  67. X    if (win->_scroll)
  68. X      scroll(win);
  69. X    else
  70. X      return(-1);
  71. X    } /* if */
  72. X  return(lin);
  73. X  } /* newline */
  74. X
  75. X/****************************************************************/
  76. X/* _Chadd() inserts character 'c' at the current cursor posi-    */
  77. X/* tion in window 'win'. If xlat is TRUE, _chadd() will handle    */
  78. X/* things like tab, newline, cr etc.; otherwise the character    */
  79. X/* is simply output.                        */
  80. X/****************************************************************/
  81. X
  82. Xint _chadd(win, c, xlat)
  83. X  register WINDOW    *win;
  84. X  char             c;
  85. X  bool             xlat;
  86. X  {
  87. X  short    x = win->_curx;
  88. X  short    y = win->_cury;
  89. X  short    newx;
  90. X  short    ch = c;
  91. X  short    ts = win->_tabsize;
  92. X
  93. X  ch &= 0xff;            /* kill any sing-extend */
  94. X  if (y >= win->_maxy  ||  x >= win->_maxx  ||  y < 0  ||  x < 0)
  95. X    return(ERR);
  96. X
  97. X  if (xlat)
  98. X    {
  99. X    switch (ch)
  100. X      {
  101. X      case '\t':  for (newx = ((x/ts) + 1) * ts; x < newx; x++)
  102. X            {
  103. X            if (waddch(win, ' ') == ERR)
  104. X              return(ERR);
  105. X            if (win->_curx == 0)    /* if tab to next line */
  106. X              return(OK);        /* exit the loop */
  107. X            } /* for */
  108. X          return(OK);
  109. X      case '\n':  if (_cursvar.autocr && !(_cursvar.raw)) /* if lf -> crlf */
  110. X            x = 0;
  111. X          if ((y = newline(win, y)) < 0)
  112. X            return(ERR);
  113. X          win->_cury = y;
  114. X          win->_curx = x;
  115. X          return(OK);
  116. X      case '\r':  x = 0;
  117. X          win->_curx = x;
  118. X          return(OK);
  119. X      case '\b':  if (--x < 0)            /* no back over left margin */
  120. X            x = 0;
  121. X          win->_curx = x;
  122. X          return(OK);
  123. X      case 0x7f:  if (waddch(win,'^') == ERR)
  124. X            return(ERR);
  125. X          return(waddch(win,'?'));
  126. X      default:      break;
  127. X      } /* switch */
  128. X    if (ch < ' ')            /* handle control chars */
  129. X      {
  130. X      if (waddch(win,'^') == ERR)
  131. X    return(ERR);
  132. X      return(waddch(win,c + '@'));
  133. X      } /* if */
  134. X    } /* if xlat*/
  135. X
  136. X  ch |= (win->_attrs & ATR_MSK);
  137. X  if (win->_line[y][x] != ch)        /* only if data change */
  138. X    {
  139. X    if (win->_minchng[y] == _NO_CHANGE)
  140. X      win->_minchng[y] = win->_maxchng[y] = x;
  141. X    else
  142. X      {
  143. X      if (x < win->_minchng[y])
  144. X    win->_minchng[y] = x;
  145. X      else
  146. X    {
  147. X    if (x > win->_maxchng[y])
  148. X      win->_maxchng[y] = x;
  149. X    } /* else */
  150. X      } /* else */
  151. X    } /* if */
  152. X  win->_line[y][x++] = ch;
  153. X  if (x >= win->_maxx)            /* wrap around test */
  154. X    {
  155. X    x = 0;
  156. X    if ((y = newline(win, y)) < 0)
  157. X      return(ERR);
  158. X    } /* if */
  159. X  win->_curx = x;
  160. X  win->_cury = y;
  161. X  return(OK);
  162. X  } /* _chadd */
  163. X
  164. X/****************************************************************/
  165. X/* Addch() inserts character 'c' at the current cursor posi-    */
  166. X/* tion in stdscr, and takes any actions as dictated by the    */
  167. X/* character.                            */
  168. X/****************************************************************/
  169. X
  170. Xint addch(c)
  171. X  char     c;
  172. X  {
  173. X  return (_chadd(stdscr,c,TRUE));
  174. X  } /* addch */
  175. X
  176. X/****************************************************************/
  177. X/* Waddch() inserts character 'c' at the current cursor posi-    */
  178. X/* tion in window 'win', and takes any actions as dictated by    */
  179. X/* the character.                        */
  180. X/****************************************************************/
  181. X
  182. Xint waddch(win,c)
  183. X  WINDOW *win;
  184. X  char     c;
  185. X  {
  186. X  return (_chadd(win,c,TRUE));
  187. X  } /* waddch */
  188. X
  189. X/****************************************************************/
  190. X/* Mvaddch() moves to position in stdscr, then inserts charac-    */
  191. X/* ter 'c' at that point, and takes any actions as dictated by    */
  192. X/* the character.                        */
  193. X/****************************************************************/
  194. X
  195. Xint mvaddch(y,x,c)
  196. X  int     x;
  197. X  int     y;
  198. X  char     c;
  199. X  {
  200. X  if (wmove(stdscr,y,x) == ERR)
  201. X    return(ERR);
  202. X  return (_chadd(stdscr,c,TRUE));
  203. X  } /* mvaddch */
  204. X
  205. X/****************************************************************/
  206. X/* Mvwaddch() moves to position in window 'win', then inserts    */
  207. X/* character 'c' at that point in the window, and takes any    */
  208. X/* actions as dictated by the character.            */
  209. X/****************************************************************/
  210. X
  211. Xint mvwaddch(win,y,x,c)
  212. X  WINDOW *win;
  213. X  int      x;
  214. X  int      y;
  215. X  char      c;
  216. X  {
  217. X  if (wmove(win,y,x) == ERR)
  218. X    return(ERR);
  219. X  return (_chadd(win,c,TRUE));
  220. X  } /* mvwaddch */
  221. X
  222. X/****************************************************************/
  223. X/* Addrawch() inserts character 'c' at the current cursor    */
  224. X/* position in stdscr, disregarding any traditional interpre-    */
  225. X/* tation of the character.                    */
  226. X/****************************************************************/
  227. X
  228. Xint addrawch(c)
  229. X  char     c;
  230. X  {
  231. X  return (_chadd(stdscr,c,FALSE));
  232. X  } /* addrawch */
  233. X
  234. X/****************************************************************/
  235. X/* Waddrawch() inserts character 'c' at the current cursor    */
  236. X/* position in window 'win', disregarding any traditional in-    */
  237. X/* terpretation of the character.                */
  238. X/****************************************************************/
  239. X
  240. Xint waddrawch(win,c)
  241. X  WINDOW *win;
  242. X  char     c;
  243. X  {
  244. X  return (_chadd(win,c,FALSE));
  245. X  } /* waddrawch */
  246. X
  247. X/****************************************************************/
  248. X/* Mvaddrawch() moves to position in stdscr, then inserts cha-    */
  249. X/* racter 'c' at that point, disregarding any traditional in-    */
  250. X/* terpretation of the character.                */
  251. X/****************************************************************/
  252. X
  253. Xint mvaddrawch(y,x,c)
  254. X  int     x;
  255. X  int     y;
  256. X  char     c;
  257. X  {
  258. X  if (wmove(stdscr,y,x) == ERR)
  259. X    return(ERR);
  260. X  return (_chadd(stdscr,c,FALSE));
  261. X  } /* mvaddrawch */
  262. X
  263. X/****************************************************************/
  264. X/* Mvwaddrawch() moves to position in window 'win', then in-    */
  265. X/* serts character 'c' at that point in the window, disregar-    */
  266. X/* ding any traditional interpretation of the character.    */
  267. X/****************************************************************/
  268. X
  269. Xint mvwaddrawch(win,y,x,c)
  270. X  WINDOW *win;
  271. X  int      x;
  272. X  int      y;
  273. X  char      c;
  274. X  {
  275. X  if (wmove(win,y,x) == ERR)
  276. X    return(ERR);
  277. X  return (_chadd(win,c,FALSE));
  278. X  } /* mvwaddrawch */
  279. END_OF_charadd.c
  280. if test 7261 -ne `wc -c <charadd.c`; then
  281.     echo \"charadd.c\" unpacked with wrong size!
  282. fi
  283. # end of overwriting check
  284. fi
  285. if test -f charins.c -a "${1}" != "-c" ; then 
  286.   echo Will not over-write existing file \"charins.c\"
  287. else
  288. echo Extracting - \"charins.c\"
  289. sed "s/^X//" >charins.c <<'END_OF_charins.c'
  290. X/****************************************************************/
  291. X/* Winsch() routine of the PCcurses package            */
  292. X/*                                */
  293. X/****************************************************************/
  294. X/* This version of curses is based on ncurses, a curses version    */
  295. X/* originally written by Pavel Curtis at Cornell University.    */
  296. X/* I have made substantial changes to make it run on IBM PC's,    */
  297. X/* and therefore consider myself free to make it public domain.    */
  298. X/*                Bjorn Larsson (bl@infovox.se)    */
  299. X/****************************************************************/
  300. X/* 1.4:  Use of short wherever possible. Portability        */
  301. X/*     improvements:                    900114    */
  302. X/* 1.3:     MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  303. X/* 1.2:     Max limits off by 1. Fixed thanks to S. Creps:    881002    */
  304. X/* 1.1:     Added 'raw' output routines (allows PC charac-        */
  305. X/*     ters < 0x20 to be displayed:            880306    */
  306. X/* 1.0:     Release:                    870515    */
  307. X/****************************************************************/
  308. X
  309. X#include <curses.h>
  310. X#include <curspriv.h>
  311. X
  312. Xchar _curses_charins_rcsid[] = "@(#)charins.c    v.1.4  - 900114";
  313. X
  314. X/****************************************************************/
  315. X/* _Chins() inserts character 'c' at the cursor position in    */
  316. X/* window 'win'. If xlat is true, normal character translation    */
  317. X/* is performed; If xlat is false, the character is output 'as    */
  318. X/* is'.                                */
  319. X/****************************************************************/
  320. X
  321. Xstatic    int    _chins(win,c,xlat)
  322. X  WINDOW    *win;
  323. X  char         c;
  324. X  bool         xlat;
  325. X  {
  326. X  short        *temp1;
  327. X  short        *temp2;
  328. X  short        *end;
  329. X  short         x = win->_curx;
  330. X  short         y = win->_cury;
  331. X  short         maxx = win->_maxx - 1;
  332. X
  333. X  if((c < ' ') && (c == '\n' || c == '\r' || c == '\t' || c == '\b'))
  334. X    return(_chadd(win,c,xlat));
  335. X  end = &win->_line[y][x];
  336. X  temp1 = &win->_line[y][maxx];
  337. X  temp2 = temp1 - 1;
  338. X  if((c < ' ') && xlat)            /* if CTRL-char make space for 2 */
  339. X    temp2--;
  340. X  while (temp1 > end)
  341. X    *temp1-- = *temp2--;
  342. X  win->_maxchng[y] = maxx;
  343. X  if ((win->_minchng[y] == _NO_CHANGE) || (win->_minchng[y] > x))
  344. X    win->_minchng[y] = x;
  345. X  return(_chadd(win,c,xlat));        /* fixes CTRL-chars too */
  346. X  } /* _chins */
  347. X
  348. X/****************************************************************/
  349. X/* Insch() inserts character 'c' at the cursor position in    */
  350. X/* stdscr. The cursor is advanced.                */
  351. X/****************************************************************/
  352. X
  353. Xint insch(c)
  354. X  char c;
  355. X  {
  356. X  return(_chins(stdscr,c,TRUE));
  357. X  } /* insch */
  358. X
  359. X/****************************************************************/
  360. X/* Winsch() inserts character 'c' at the cursor position in    */
  361. X/* window 'win'. The cursor is advanced.            */
  362. X/****************************************************************/
  363. X
  364. Xint winsch(win,c)
  365. X  WINDOW *win;
  366. X  char c;
  367. X  {
  368. X  return(_chins(win,c,TRUE));
  369. X  } /* winsch */
  370. X
  371. X/****************************************************************/
  372. X/* Mvinsch() moves the stdscr cursor to a new position, then    */
  373. X/* inserts character 'c' at the cursor position in stdscr. The    */
  374. X/* cursor is advanced.                        */
  375. X/****************************************************************/
  376. X
  377. Xint mvinsch(y,x,c)
  378. X  int  y;
  379. X  int  x;
  380. X  char c;
  381. X  {
  382. X  if (wmove(stdscr,y,x) == ERR)
  383. X    return(ERR);
  384. X  return(_chins(stdscr,c,TRUE));
  385. X  } /* mvinsch */
  386. X
  387. X/****************************************************************/
  388. X/* Mvwinsch() moves the cursor of window 'win' to a new posi-    */
  389. X/* tion, then inserts character 'c' at the cursor position in    */
  390. X/* window 'win'. The cursor is advanced.            */
  391. X/****************************************************************/
  392. X
  393. Xint mvwinsch(win,y,x,c)
  394. X  WINDOW *win;
  395. X  int  y;
  396. X  int  x;
  397. X  char c;
  398. X  {
  399. X  if (wmove(win,y,x) == ERR)
  400. X    return(ERR);
  401. X  return(_chins(win,c,TRUE));
  402. X  } /* mvwinsch */
  403. X
  404. X/****************************************************************/
  405. X/* Insrawch() inserts character 'c' at the cursor position in    */
  406. X/* stdscr. Control characters are not interpreted, and the    */
  407. X/* cursor is advanced.                        */
  408. X/****************************************************************/
  409. X
  410. Xint insrawch(c)
  411. X  char c;
  412. X  {
  413. X  return(_chins(stdscr,c,FALSE));
  414. X  } /* insrawch */
  415. X
  416. X/****************************************************************/
  417. X/* Winsrawch() inserts character 'c' at the cursor position in    */
  418. X/* window 'win'. Control characters are not interpreted, and    */
  419. X/* the cursor is advanced.                    */
  420. X/****************************************************************/
  421. X
  422. Xint winsrawch(win,c)
  423. X  WINDOW *win;
  424. X  char c;
  425. X  {
  426. X  return(_chins(win,c,FALSE));
  427. X  } /* winsrawch */
  428. X
  429. X/****************************************************************/
  430. X/* Mvinsrawch() moves the stdscr cursor to a new position, then    */
  431. X/* inserts character 'c' at the cursor position in stdscr.    */
  432. X/* Control characters are not interpreted, and    the cursor is    */
  433. X/* advanced.                            */
  434. X/****************************************************************/
  435. X
  436. Xint mvinsrawch(y,x,c)
  437. X  int  y;
  438. X  int  x;
  439. X  char c;
  440. X  {
  441. X  if (wmove(stdscr,y,x) == ERR)
  442. X    return(ERR);
  443. X  return(_chins(stdscr,c,FALSE));
  444. X  } /* mvinsrawch */
  445. X
  446. X/****************************************************************/
  447. X/* Mvwinsrawch() moves the cursor of window 'win' to a new    */
  448. X/* position, then inserts character 'c' at the cursor position    */
  449. X/* in window 'win'. Control characters are not interpreted, and    */
  450. X/* the cursor is advanced.                    */
  451. X/****************************************************************/
  452. X
  453. Xint mvwinsrawch(win,y,x,c)
  454. X  WINDOW *win;
  455. X  int  y;
  456. X  int  x;
  457. X  char c;
  458. X  {
  459. X  if (wmove(win,y,x) == ERR)
  460. X    return(ERR);
  461. X  return(_chins(win,c,FALSE));
  462. X  } /* mvwinsrawch */
  463. END_OF_charins.c
  464. if test 5564 -ne `wc -c <charins.c`; then
  465.     echo \"charins.c\" unpacked with wrong size!
  466. fi
  467. # end of overwriting check
  468. fi
  469. if test -f curses68.c -a "${1}" != "-c" ; then 
  470.   echo Will not over-write existing file \"curses68.c\"
  471. else
  472. echo Extracting - \"curses68.c\"
  473. sed "s/^X//" >curses68.c <<'END_OF_curses68.c'
  474. X/****************************************************************/
  475. X/* Low-level I/O functions of the PCcurses package, 'C' version    */
  476. X/****************************************************************/
  477. X/*     NOTE! NOTE! NOTE! NOTE! NOTE! NOTE! NOTE! NOTE!    */
  478. X/* This version is for a 68000 stand-alone VT100 version    */
  479. X/****************************************************************/
  480. X/* This version of curses is based on ncurses, a curses version    */
  481. X/* originally written by Pavel Curtis at Cornell University.    */
  482. X/* I have made substantial changes to make it run on IBM PC's,    */
  483. X/* and therefore consider myself free make it public domain.    */
  484. X/*                Bjorn Larsson (bl@infovox.se)    */
  485. X/****************************************************************/
  486. X/* 1.4:  Functional:                    900114    */
  487. X/****************************************************************/
  488. X
  489. X#include <curses.h>
  490. X#include <curspriv.h>
  491. X
  492. Xtypedef struct
  493. X  {
  494. X  char *name;                /* Device/file name */
  495. X  int (* inch)  ();            /* Address of input routine */
  496. X  int (* outch) ();            /* Address of output routine */
  497. X  int (* intst) ();            /* Address of input test routine */
  498. X  int    id;
  499. X  } _chan_desc;
  500. X
  501. Xstatic char _curses_curse68_rcsid[] = "@(#)curses68.c   v.1.4  - 900114";
  502. X
  503. Xextern    _chan_desc _chan_tab[];        /* This one may be accessed */
  504. X
  505. Xstatic    char    clearseq[] = "\033[2J\033[H";
  506. Xstatic    char    seqbuf[20];
  507. X
  508. Xstatic    char    isrev    = 0;
  509. X
  510. Xstatic    int    myrow = 1000;
  511. Xstatic    int    mycol = 1000;
  512. X
  513. X/****************************************************************/
  514. X/* _Cursescattr() writes char 'chr' with attributes 'attr' to    */
  515. X/* the current cursor location.                    */
  516. X/****************************************************************/
  517. X
  518. Xvoid _cursescattr(chr, attr)
  519. X  char    chr;
  520. X  char    attr;
  521. X  {
  522. X  if ((attr & 0x70) == 0x70)
  523. X    {
  524. X    if(!isrev)
  525. X      {
  526. X      (*_chan_tab[1].outch)(0x1b);
  527. X      (*_chan_tab[1].outch)('[');
  528. X      (*_chan_tab[1].outch)('7');
  529. X      (*_chan_tab[1].outch)('m');
  530. X      isrev = 1;
  531. X      } /* if */
  532. X    }
  533. X  else
  534. X    {
  535. X    if (isrev)
  536. X      {
  537. X      (*_chan_tab[1].outch)(0x1b);
  538. X      (*_chan_tab[1].outch)('[');
  539. X      (*_chan_tab[1].outch)('0');
  540. X      (*_chan_tab[1].outch)('m');
  541. X      isrev = 0;
  542. X      } /* if */
  543. X    } /* else */
  544. X  if ((_cursvar.cursrow < LINES-1) || (_cursvar.curscol < COLS-1))
  545. X    {
  546. X    (*_chan_tab[1].outch)(chr);
  547. X    if (mycol++ >= 80)
  548. X      {
  549. X      mycol = 0;
  550. X      myrow++;
  551. X      } /* if */
  552. X    } /* if */
  553. X  } /* _cursescattr */    
  554. X
  555. X/****************************************************************/
  556. X/* _Cursescursor() sets the cursor position in video page 0.    */
  557. X/* 'row' and 'column' are the cursor address. If 'row' is set    */
  558. X/*  to 25, no cursor at    all is displayed.            */
  559. X/****************************************************************/
  560. X
  561. Xvoid _cursescursor(row, column)
  562. X  int    row;
  563. X  int    column;
  564. X  {
  565. X  char    *p;
  566. X  char    buf[15];
  567. X
  568. X  if ((row == myrow) && (column == mycol))
  569. X    return;
  570. X  (*_chan_tab[1].outch)(0x1b);
  571. X  sprintf(seqbuf,"\033[%d;%dH",row+1, column+1);
  572. X  for (p = seqbuf; *p; p++)
  573. X    (*_chan_tab[1].outch)(*p);
  574. X  myrow = row;
  575. X  mycol = column;
  576. X  }/* _cursescursor */
  577. X
  578. X/****************************************************************/
  579. X/* _Cursesgcols() returns the current number of columns on the    */
  580. X/* screen.                            */
  581. X/****************************************************************/
  582. X
  583. Xint _cursesgcols()
  584. X  {
  585. X  return(80);
  586. X  } /* _cursesgcols */
  587. X
  588. X/****************************************************************/
  589. X/* _Cursesputc() outputs character 'chr' to screen in tty    */
  590. X/* fashion. If a colour mode is active, the character is writ-    */
  591. X/* ten with colour 'colour'.                    */
  592. X/****************************************************************/
  593. X
  594. Xvoid _cursesputc(chr, color)
  595. X  char    chr;
  596. X  char    color;
  597. X  {
  598. X  if (_cursvar.cursrow >= LINES-1)
  599. X    return;
  600. X  if (_cursvar.curscol >= COLS-1)
  601. X    return;
  602. X  (*_chan_tab[1].outch)(chr);
  603. X  if (mycol++ >= 80)
  604. X    {
  605. X    mycol = 0;
  606. X    myrow++;
  607. X    } /* if */
  608. X  } /* _cursesputc */
  609. X
  610. X/****************************************************************/
  611. X/* _Cursesscroll() scrolls a window in the current page up or    */
  612. X/*  down. Urow, lcol, lrow,rcol are the window coordinates.    */
  613. X/* Lines is the number of lines to scroll. If 0, clears the    */
  614. X/* window, if < 0 scrolls down, > 0 scrolls up. Blanks areas    */
  615. X/* that are left, and sets character attributes to attr. If in    */
  616. X/* a colour graphics mode, fills them with the colour 'attr'    */
  617. X/* instead.                            */
  618. X/****************************************************************/
  619. X
  620. Xvoid _cursesscroll(urow, lcol, lrow, rcol, lines, attr)
  621. X  int    urow;
  622. X  int    lcol;
  623. X  int    lrow;
  624. X  int    rcol;
  625. X  int    lines;
  626. X  char attr;
  627. X  {
  628. X  char    *p;
  629. X
  630. X  for (p = clearseq; *p; p++)
  631. X    (*_chan_tab[1].outch)(*p);
  632. X  } /* _cursesscroll */
  633. X
  634. X/****************************************************************/
  635. X/* _Cursesgcmode() returns the current cursor type. Bits 8-15    */
  636. X/* of the return value is the start scan row, and bits 0-7 is    */
  637. X/* the end scan row.                        */
  638. X/****************************************************************/
  639. X
  640. Xint _cursesgcmode()
  641. X  {
  642. X  return(0x0f00);
  643. X  } /* _cursesgcmode */
  644. X
  645. X/****************************************************************/
  646. X/* _Cursescmode() sets the cursor type to begin in scan line    */
  647. X/* startrow and end in scan line endrow. Both values should be    */
  648. X/* 0-31.                            */
  649. X/****************************************************************/
  650. X
  651. Xvoid _cursescmode(startrow, endrow)
  652. X  int    startrow;
  653. X  int    endrow;
  654. X  {
  655. X  } /* _cursescmode */
  656. X
  657. X/****************************************************************/
  658. X/* _Curseskey() returns the next key code struck at the key-    */
  659. X/* board. If the low 8 bits are 0, the upper bits contain the    */
  660. X/* extended character code. If bit 0-7 are non-zero, the upper    */
  661. X/* bits = 0.                            */
  662. X/****************************************************************/
  663. X
  664. Xint _curseskey()
  665. X  {
  666. X  return ((*_chan_tab[1].inch)());
  667. X  } /* _curseskey */
  668. X
  669. X/****************************************************************/
  670. X/* _Curseskeytst() returns 1 if a keyboard character is avail-    */
  671. X/* able, 0 otherwise.                        */
  672. X/****************************************************************/
  673. X
  674. Xchar _curseskeytst()
  675. X  {
  676. X  return((*_chan_tab[1].intst)());
  677. X  } /*_curseskeytst */
  678. X
  679. X/****************************************************************/
  680. X/* _Cursesgcb() returns 1 if MSDOS BREAK CHECK is on, else 0.    */
  681. X/****************************************************************/
  682. X
  683. Xint _cursesgcb()
  684. X  {
  685. X  return(1);
  686. X  } /* _cursesgcb */
  687. X
  688. X/****************************************************************/
  689. X/* _Cursesscb() sets MSDOS BREAK CHECK according to 'setting'.    */
  690. X/****************************************************************/
  691. X
  692. Xvoid _cursesscb(setting)
  693. X  int setting;
  694. X  {
  695. X  } /* _cursesscb */
  696. X
  697. X#undef getch
  698. X
  699. X/****************************************************************/
  700. X/* Getch() read one character from the keyboard without any    */
  701. X/* interpretation whatever.                    */
  702. X/****************************************************************/
  703. X
  704. Xint    getch()
  705. X  {
  706. X  return ((*_chan_tab[1].inch)());
  707. X  } /* getch */
  708. END_OF_curses68.c
  709. if test 7011 -ne `wc -c <curses68.c`; then
  710.     echo \"curses68.c\" unpacked with wrong size!
  711. fi
  712. # end of overwriting check
  713. fi
  714. if test -f make.man -a "${1}" != "-c" ; then 
  715.   echo Will not over-write existing file \"make.man\"
  716. else
  717. echo Extracting - \"make.man\"
  718. sed "s/^X//" >make.man <<'END_OF_make.man'
  719. XMAKE(1)            MS-DOS Programmer's Manual            MAKE(1)
  720. X
  721. XNAME
  722. X   make - maintain program groups
  723. X
  724. XSYNOPSIS
  725. X   make [-f <makefile>] [-ainpqrst] [<target>...]
  726. X
  727. XDESCRIPTION
  728. X   Make executes commands in makefile to update one or more target names. Name
  729. X   is typically a program. If no -f option is present, `makefile' is tried. If
  730. X   makefile is `-', the standard input is taken. More than one -f option may
  731. X   appear
  732. X
  733. X   Make updates a target if it depends on prerequisite files that have been
  734. X   modified since the target was last modified, or if the target does not
  735. X   exist.
  736. X
  737. X   Makefile contains a sequence of entries that specify dependencies. The
  738. X   first line of an entry is a blank-separated list of targets, then a colon,
  739. X   then a list of prerequisite files. Text following a semicolon, and all
  740. X   following lines that begin with a tab, are shell commands to be executed to
  741. X   update the target. If a name appears on the left of more than one `colon'
  742. X   line, then it depends on all of the names on the right of the colon on
  743. X   those lines, but only one command sequence may be specified for it. If a
  744. X   name appears on a line with a double colon :: then the command sequence
  745. X   following that line is performed only if the name is out of date with
  746. X   respect to the names to the right of the double colon, and is not affected
  747. X   by other double colon lines on which that name may appear.
  748. X
  749. X   Sharp and newline surround comments.
  750. X
  751. X   The following makefile says that `pgm' depends on two files `a.obj' and
  752. X   `b.obj', and that they in turn depend on `.c' files and a common file
  753. X   `incl'.
  754. X
  755. X          pgm: a.obj b.obj
  756. X            cc a.obj b.obj -lm -o pgm
  757. X          a.obj: incl a.c
  758. X            cc -c a.c
  759. X          b.obj: incl b.c
  760. X            cc -c b.c
  761. X
  762. X   Makefile entries of the form
  763. X
  764. X          string1 = string2
  765. X
  766. X   are macro definitions. Subsequent appearances of $(string1) or ${string1}
  767. X   are replaced by string2. If string1 is a single character, the parentheses
  768. X   or braces are optional.
  769. X
  770. X   Make infers prerequisites for files for which makefile gives no construc-
  771. X   tion commands. For example, a `.c' file may be inferred as prerequisite for
  772. X   a `.obj' file and be compiled to produce the `.obj' file. Thus the prece-
  773. X   ding example can be done more briefly:
  774. X
  775. X          pgm: a.obj b.obj
  776. X            cc a.obj b.obj -lm -o pgm
  777. X          a.obj b.obj: incl
  778. X
  779. X   Prerequisites are inferred according to selected suffixes listed as the
  780. X   `prerequisites' for the special name `.SUFFIXES'; multiple lists accumu-
  781. X   late; an empty list clears what came before. Order is significant; the
  782. X   first possible name for which both a file and a rule as described in the
  783. X   next paragraph exist is inferred.  The default list is
  784. X
  785. X          .SUFFIXES: .obj .asm .c
  786. X
  787. X   The rule to create a file with suffix s2 that depends on a similarly named
  788. X   file with suffix s1 is specified as an entry for the `target' s1s2.  In
  789. X   such an entry, the special macros
  790. X
  791. X       $* stands for the target name with suffix deleted,
  792. X    $@ for the full target name,
  793. X    $< for the complete list of prerequisites,
  794. X    $? for the list of prerequisites that are out of date.
  795. X
  796. X   For example, a rule for making optimized `.obj' files from `.c' files is
  797. X
  798. X          .c.obj: ; cc -c -O -o $@ $*.c
  799. X
  800. X   Certain macros are used by the default inference rules to communicate op-
  801. X   tional arguments to any resulting compilations.  In particular, `CFLAGS' is
  802. X   used for cc(1) options, and AFLAGS for masm options. In addition, the macro
  803. X   `MFLAGS' is filled in with the initial command line options supplied to
  804. X   make. This simplifies maintaining a hierarchy of makefiles as one may then
  805. X   invoke make on makefiles in subdirectories and pass along useful options.
  806. X
  807. X   Command lines are executed one at a time. First execution of the command
  808. X   is attempted directly from make. If this fails, a secondary COMMAND.COM
  809. X   processor is invoked to do the job. For commands executed by a secondary
  810. X   COMMAND.COM processor, exit status may not be correct, which is a flaw in
  811. X   MSDOS.
  812. X
  813. X   A command line is printed when it is executed unless the special target
  814. X   `.SILENT' is in makefile, or the first character of the command is `@'.
  815. X
  816. X   Commands returning nonzero exit status cause make to terminate unless the
  817. X   special target `.IGNORE' is in makefile or the command begins with the cha-
  818. X   racter sequence <tab><hyphen>, or if the `-i' option was given.
  819. X
  820. X   Interrupt and quit cause the target to be deleted unless the target is a
  821. X   directory or depends on the special name `.PRECIOUS'.
  822. X
  823. XOPTION
  824. X   -a   Disregard date/time stamps, and perform all commands that would be
  825. X       necessary to update the requested final target(s).
  826. X   -f   Use the next command line token for the makefile name. If this is '-'
  827. X       then use standard input.
  828. X   -i   Equivalent to the special entry `.IGNORE:'. A single command may be
  829. X       forced to behave this way by preceding it by '<tab>-'.
  830. X   -n   Trace and print, but do not execute the commands needed to update the
  831. X       targets.
  832. X   -p   Print all macros and targets. Good for debugging your makefiles.
  833. X   -q   Causes make to return the up-to-date-ness of the target as exit
  834. X       status.
  835. X   -r   Equivalent to an initial special entry `.SUFFIXES:' with no list. This
  836. X       means that the built-in inference rules are not used.
  837. X   -s   Equivalent to the special entry `.SILENT:'. A single command may be
  838. X       forced to behave this way by preceding it by '@'.
  839. X   -t   Touch, i.e. update the modified date of targets, without executing any
  840. X       commands.
  841. X
  842. XFILES
  843. X   makefile, command.com
  844. X
  845. XSEE ALSO
  846. X   touch
  847. X
  848. XRESTRICTIONS
  849. X   Some commands return nonzero status inappropriately.  Use -i to overcome
  850. X   the difficulty.
  851. X
  852. X   If a command is executed by an invocation a secondary COMMAND.COM, and
  853. X   ties to set environment variables, these settings will only affect the
  854. X   environment of that secondary command processor. As soon asit terminates,
  855. X   the settings are lost. Also, COMMAND.COM always return successful status,
  856. X   even if it tries to execute a non-existen command. In general, the inten-
  857. X   tion is that COMMAND.COM is only to be invoked to run simple commands as
  858. X   COPY, TYPE, DEL and the like.
  859. END_OF_make.man
  860. if test 6185 -ne `wc -c <make.man`; then
  861.     echo \"make.man\" unpacked with wrong size!
  862. fi
  863. # end of overwriting check
  864. fi
  865. if test -f newwin.c -a "${1}" != "-c" ; then 
  866.   echo Will not over-write existing file \"newwin.c\"
  867. else
  868. echo Extracting - \"newwin.c\"
  869. sed "s/^X//" >newwin.c <<'END_OF_newwin.c'
  870. X/****************************************************************/
  871. X/* Newwin(), subwin() routines of the PCcurses package        */
  872. X/*                                */
  873. X/****************************************************************/
  874. X/* This version of curses is based on ncurses, a curses version    */
  875. X/* originally written by Pavel Curtis at Cornell University.    */
  876. X/* I have made substantial changes to make it run on IBM PC's,    */
  877. X/* and therefore consider myself free to make it public domain.    */
  878. X/*                Bjorn Larsson (bl@infovox.se)    */
  879. X/****************************************************************/
  880. X/* 1.4:  References to win->borderchar[] removed due to        */
  881. X/*     re-defined border() functions. Use of short        */
  882. X/*     wherever possible. Bug in subwin() did not        */
  883. X/*     allow subwin to be the same size as the origi-        */
  884. X/*     nal window. Portability improvements:        900114    */
  885. X/* 1.3:  MSC '-W3', Turbo'C' '-w -w-pro' checks.        */
  886. X/*     Support for border(), wborder() functions:    881005    */
  887. X/* 1.2:     Other max limits off by 1. Fixed thanks to        */
  888. X/*     S. Creps:                    881002    */
  889. X/* 1.1:     Fix in subwin: '+/-1' error when checking that        */
  890. X/*     subwindow fits in parent window:        880305    */
  891. X/* 1.0:     Release:                    870515    */
  892. X/****************************************************************/
  893. X
  894. X#include <stdio.h>
  895. X#include <curses.h>
  896. X#include <curspriv.h>
  897. X
  898. Xchar _curses_newwin_rcsid[] = "@(#)newwin.c     v.1.4  - 900114";
  899. X
  900. Xextern    char    *malloc();
  901. Xextern    char    *calloc();
  902. Xextern    void     free();
  903. X
  904. X/****************************************************************/
  905. X/* Makenew() allocates all data for a new window except the    */
  906. X/* actual lines themselves.                    */
  907. X/****************************************************************/
  908. X
  909. Xstatic WINDOW *makenew(num_lines, num_columns, begy, begx)
  910. X  int    num_lines;
  911. X  int    num_columns;
  912. X  int    begy;
  913. X  int    begx;
  914. X  {
  915. X  short         i;
  916. X  WINDOW    *win;
  917. X
  918. X  /* allocate the window structure itself */
  919. X
  920. X  if ((win = (WINDOW *) malloc(sizeof(WINDOW))) == NULL)
  921. X    return ((WINDOW *) ERR);
  922. X
  923. X  /* allocate the line pointer array */
  924. X
  925. X  if ((win->_line = (short **) calloc(num_lines, sizeof (short *))) == NULL)
  926. X    {
  927. X    free(win);
  928. X    return((WINDOW *) ERR);
  929. X    }
  930. X
  931. X  /* allocate the minchng and maxchng arrays */
  932. X
  933. X  if ((win->_minchng = (short *) calloc(num_lines, sizeof(short))) == NULL)
  934. X    {
  935. X    free(win);
  936. X    free(win->_line);
  937. X    return((WINDOW *) ERR);
  938. X    }
  939. X  if ((win->_maxchng = (short *) calloc(num_lines, sizeof(short))) == NULL)
  940. X    {
  941. X    free(win);
  942. X    free(win->_line);
  943. X    free(win->_minchng);
  944. X    return((WINDOW *) ERR);
  945. X    }
  946. X
  947. X  /* initialize window variables */
  948. X
  949. X  win->_curx      = 0;
  950. X  win->_cury      = 0;
  951. X  win->_maxy      = num_lines;
  952. X  win->_maxx      = num_columns;
  953. X  win->_begy      = begy;
  954. X  win->_begx      = begx;
  955. X  win->_flags     = 0;
  956. X  win->_attrs     = ATR_NRM;
  957. X  win->_tabsize   = 8;
  958. X  win->_clear     = (bool) ((num_lines == LINES) && (num_columns == COLS));
  959. X  win->_leave     = FALSE;
  960. X  win->_scroll    = FALSE;
  961. X  win->_nodelay   = FALSE;
  962. X  win->_keypad    = FALSE;
  963. X  win->_regtop    = 0;
  964. X  win->_regbottom = num_lines - 1;
  965. X
  966. X  /* init to say window unchanged */
  967. X
  968. X  for (i = 0; i < num_lines; i++)
  969. X    {
  970. X    win->_minchng[i] = 0;
  971. X    win->_maxchng[i] = num_columns-1;
  972. X    }
  973. X
  974. X  /* set flags for window properties */
  975. X
  976. X  if ((begy + num_lines) == LINES)
  977. X    {
  978. X    win->_flags |= _ENDLINE;
  979. X    if ((begx == 0) && (num_columns == COLS) && (begy == 0))
  980. X      win->_flags |= _FULLWIN;
  981. X    } /* if */
  982. X
  983. X  if (((begy + num_lines) == LINES)
  984. X        &&
  985. X      ((begx + num_columns) == COLS))
  986. X    win->_flags |= _SCROLLWIN;
  987. X  return(win);
  988. X  } /* makenew */
  989. X
  990. X/****************************************************************/
  991. X/* Newwin() creates a new window with size num_lines * num_co-    */
  992. X/* lumns, and origin begx,begy relative to the SCREEN. Special    */
  993. X/* case: if num_lines and/or num_columns is 0, the remainder of    */
  994. X/* the screen is used.                        */
  995. X/****************************************************************/
  996. X
  997. XWINDOW *newwin(num_lines, num_columns, begy, begx)
  998. X  int    num_lines;
  999. X  int    num_columns;
  1000. X  int    begy;
  1001. X  int    begx;
  1002. X  {
  1003. X  WINDOW    *win;
  1004. X  short        *ptr;
  1005. X  short         i, j;
  1006. X
  1007. X  if (num_lines == 0)
  1008. X    num_lines = LINES - begy;
  1009. X  if (num_columns == 0)
  1010. X    num_columns = COLS - begx;
  1011. X  if ((win = makenew(num_lines, num_columns, begy, begx)) == (WINDOW *) ERR)
  1012. X    return((WINDOW *) ERR);
  1013. X  for (i = 0; i < num_lines; i++)    /* make and clear the lines */
  1014. X    {
  1015. X    if((win->_line[i] = (short *) calloc(num_columns,sizeof(short))) == NULL)
  1016. X      {
  1017. X      for (j = 0; j < i; j++)        /* if error, free all the data */
  1018. X    free(win->_line[j]);
  1019. X      free(win->_minchng);
  1020. X      free(win->_maxchng);
  1021. X      free(win->_line);
  1022. X      free(win);
  1023. X      return((WINDOW *) ERR);
  1024. X      } /* if */
  1025. X    else
  1026. X      for (ptr = win->_line[i]; ptr < win->_line[i] + num_columns;)
  1027. X    *ptr++ = ' ' | ATR_NRM;
  1028. X    } /* for */
  1029. X  return(win);
  1030. X  } /* newwin */
  1031. X
  1032. X/****************************************************************/
  1033. X/* Subwin() creates a sub-window in the 'orig' window, with    */
  1034. X/* size num_lines * num_columns, and with origin begx, begy    */
  1035. X/* relative to the SCREEN. Special case: if num_lines and/or    */
  1036. X/* num_columns is 0, the remainder of the original window is    */
  1037. X/* used. The subwindow uses the original window's line buffers    */
  1038. X/* to store it's own lines.                    */
  1039. X/****************************************************************/
  1040. X
  1041. XWINDOW *subwin(orig, num_lines, num_columns, begy, begx)
  1042. X  WINDOW    *orig;
  1043. X  int         num_lines, num_columns, begy, begx;
  1044. X  {
  1045. X  WINDOW    *win;
  1046. X  short         i, j, k;
  1047. X
  1048. X  /* make sure window fits inside the original one */
  1049. X
  1050. X  if (
  1051. X      begy < orig->_begy || 
  1052. X      begx < orig->_begx ||
  1053. X      (begy + num_lines) > (orig->_begy + orig->_maxy) ||
  1054. X      (begx + num_columns) > (orig->_begx + orig->_maxx)
  1055. X     )
  1056. X    return((WINDOW *) ERR);
  1057. X
  1058. X  if (num_lines == 0)
  1059. X    num_lines = orig->_maxy - (begy - orig->_begy);
  1060. X  if (num_columns == 0)
  1061. X    num_columns = orig->_maxx - (begx - orig->_begx);
  1062. X  if ((win = makenew(num_lines, num_columns, begy, begx)) == (WINDOW *) ERR)
  1063. X    return((WINDOW *) ERR);
  1064. X
  1065. X  /* set line pointers the same as in the original window */
  1066. X
  1067. X  j = begy - orig->_begy;
  1068. X  k = begx - orig->_begx;
  1069. X  for (i = 0; i < num_lines; i++)
  1070. X    win->_line[i] = (orig->_line[j++]) + k;
  1071. X  win->_flags |= _SUBWIN;
  1072. X  return(win);
  1073. X  } /* subwin */
  1074. END_OF_newwin.c
  1075. if test 6254 -ne `wc -c <newwin.c`; then
  1076.     echo \"newwin.c\" unpacked with wrong size!
  1077. fi
  1078. # end of overwriting check
  1079. fi
  1080. if test -f overlay.c -a "${1}" != "-c" ; then 
  1081.   echo Will not over-write existing file \"overlay.c\"
  1082. else
  1083. echo Extracting - \"overlay.c\"
  1084. sed "s/^X//" >overlay.c <<'END_OF_overlay.c'
  1085. X/****************************************************************/
  1086. X/* Overlay() and overwrite() functions of the PCcurses package    */
  1087. X/*                                */
  1088. X/****************************************************************/
  1089. X/* This version of curses is based on ncurses, a curses version    */
  1090. X/* originally written by Pavel Curtis at Cornell University.    */
  1091. X/* I have made substantial changes to make it run on IBM PC's,    */
  1092. X/* and therefore consider myself free to make it public domain.    */
  1093. X/*                Bjorn Larsson (bl@infovox.se)    */
  1094. X/****************************************************************/
  1095. X/* 1.4:  Overlaying window will not line up with over-        */
  1096. X/*     layed window's origin, but at it's 'own' origin    */
  1097. X/*     relative to the overlayed's origin. Use of short    */
  1098. X/*     wherever possible. Portability improvements:    900114    */
  1099. X/* 1.3:     MSC -W3, Turbo'C' -w -w-pro checks:        881005    */
  1100. X/* 1.2:     Max limits off by 1. Fixed thanks to S. Creps:    881002    */
  1101. X/* 1.0:     Release:                    870515    */
  1102. X/****************************************************************/
  1103. X
  1104. X#include <curses.h>
  1105. X#include <curspriv.h>
  1106. X
  1107. Xchar _curses_overlay_rcsid[] = "@(#)overlay.c    v.1.4  - 900114";
  1108. X
  1109. X/****************************************************************/
  1110. X/* Overlay() overwrites 'win1' upon 'win2', with 'win1' appea-    */
  1111. X/* ring in 'win2' at it own origin relative to 'win2's origin.    */
  1112. X/* This is a departure, but a desirable one, from the initial    */
  1113. X/* definition of this function. Overlay is transparent; blanks    */
  1114. X/* from 'win1' are not copied to 'win2'.            */
  1115. X/****************************************************************/
  1116. X
  1117. Xvoid overlay(win1, win2)
  1118. X  WINDOW    *win1, *win2;
  1119. X  {
  1120. X  short        *minchng;
  1121. X  short        *maxchng;
  1122. X  short        *w1ptr;
  1123. X  short        *w2ptr;
  1124. X  short         attrs;
  1125. X  short         col;
  1126. X  short         line;
  1127. X  short         last_line;
  1128. X  short         last_col;
  1129. X
  1130. X  last_col = min(win1->_maxx + win1->_begx, win2->_maxx) - 1;
  1131. X  last_line = min(win1->_maxy + win1->_begy, win2->_maxy) - 1;
  1132. X  attrs = win2->_attrs & ATR_MSK;
  1133. X  minchng = win2->_minchng + win1->_begy;
  1134. X  maxchng = win2->_maxchng + win1->_begy;
  1135. X
  1136. X  for(line = win1->_begy;  line <= last_line;  line++)
  1137. X    {
  1138. X    register short   fc, lc;
  1139. X
  1140. X    w1ptr = win1->_line[line - win1->_begy];
  1141. X    w2ptr = win2->_line[line] + win1->_begx;
  1142. X    fc = _NO_CHANGE;
  1143. X
  1144. X    for(col = win1->_begx;  col <= last_col;  col++)
  1145. X      {
  1146. X      if ((*w1ptr & CHR_MSK) != ' ')
  1147. X    {
  1148. X    *w2ptr = (*w1ptr & CHR_MSK) | attrs;
  1149. X    if (fc == _NO_CHANGE)
  1150. X      fc = col;
  1151. X    lc = col;
  1152. X    } /* if */
  1153. X      w1ptr++;
  1154. X      w2ptr++;
  1155. X      } /* for */
  1156. X
  1157. X    if (*minchng == _NO_CHANGE)
  1158. X      {
  1159. X      *minchng = fc;
  1160. X      *maxchng = lc;
  1161. X      } /* if */
  1162. X    else
  1163. X      if (fc != _NO_CHANGE)
  1164. X    {
  1165. X    if (fc < *minchng)
  1166. X      *minchng = fc;
  1167. X    if (lc > *maxchng)
  1168. X      *maxchng = lc;
  1169. X    } /* else if */
  1170. X    minchng++;
  1171. X    maxchng++;
  1172. X    } /* for */
  1173. X  } /* overlay */
  1174. X
  1175. X/****************************************************************/
  1176. X/* Overwrite() overwrites 'win1' upon 'win2', with 'win1' ap-    */
  1177. X/* pearing in 'win2' at it own origin relative to 'win2's ori-    */
  1178. X/* gin. This is a departure, but a desirable one, from the    */
  1179. X/* initial definition of this function. Overwrite is non-trans-    */
  1180. X/* parent; blanks from 'win1' are copied to 'win2'.        */
  1181. X/****************************************************************/
  1182. X
  1183. Xvoid    overwrite(win1, win2)
  1184. X  WINDOW    *win1, *win2;
  1185. X  {
  1186. X  short        *minchng;
  1187. X  short        *maxchng;
  1188. X  short        *w1ptr;
  1189. X  short        *w2ptr;
  1190. X  short         attrs;
  1191. X  short         col;
  1192. X  short         line;
  1193. X  short         last_line;
  1194. X  short         last_col;
  1195. X
  1196. X  last_col = min(win1->_maxx + win1->_begx, win2->_maxx) - 1;
  1197. X  last_line = min(win1->_maxy + win1->_begy, win2->_maxy) - 1;
  1198. X  attrs = win2->_attrs & ATR_MSK;
  1199. X  minchng = win2->_minchng + win1->_begy;
  1200. X  maxchng = win2->_maxchng + win1->_begy;
  1201. X
  1202. X  for(line = win1->_begy;  line <= last_line;  line++)
  1203. X    {
  1204. X    register short   fc, lc;
  1205. X
  1206. X    w1ptr = win1->_line[line - win1->_begy];
  1207. X    w2ptr = win2->_line[line] + win1->_begx;
  1208. X    fc = _NO_CHANGE;
  1209. X
  1210. X    for(col = win1->_begx;  col <= last_col;  col++)
  1211. X      {
  1212. X      if ((*w1ptr & CHR_MSK) != (*w2ptr & CHR_MSK))
  1213. X    {
  1214. X    *w2ptr = (*w1ptr & CHR_MSK) | attrs;
  1215. X    if (fc == _NO_CHANGE)
  1216. X      fc = col;
  1217. X    lc = col;
  1218. X    } /* if */
  1219. X      w1ptr++;
  1220. X      w2ptr++;
  1221. X      } /* for */
  1222. X
  1223. X    if (*minchng == _NO_CHANGE)
  1224. X      {
  1225. X      *minchng = fc;
  1226. X      *maxchng = lc;
  1227. X      } /* if */
  1228. X    else
  1229. X      if (fc != _NO_CHANGE)
  1230. X    {
  1231. X    if (fc < *minchng)
  1232. X      *minchng = fc;
  1233. X    if (lc > *maxchng)
  1234. X      *maxchng = lc;
  1235. X    } /* else if */
  1236. X    minchng++;
  1237. X    maxchng++;
  1238. X    } /* for */
  1239. X  } /* overwrite */
  1240. END_OF_overlay.c
  1241. if test 4468 -ne `wc -c <overlay.c`; then
  1242.     echo \"overlay.c\" unpacked with wrong size!
  1243. fi
  1244. # end of overwriting check
  1245. fi
  1246. if test -f strget.c -a "${1}" != "-c" ; then 
  1247.   echo Will not over-write existing file \"strget.c\"
  1248. else
  1249. echo Extracting - \"strget.c\"
  1250. sed "s/^X//" >strget.c <<'END_OF_strget.c'
  1251. X/****************************************************************/
  1252. X/* Getstr() routines of the PCcurses package            */
  1253. X/*                                */
  1254. X/****************************************************************/
  1255. X/* This version of curses is based on ncurses, a curses version    */
  1256. X/* originally written by Pavel Curtis at Cornell University.    */
  1257. X/* I have made substantial changes to make it run on IBM PC's,    */
  1258. X/* and therefore consider myself free to make it public domain.    */
  1259. X/*                Bjorn Larsson (bl@infovox.se)    */
  1260. X/****************************************************************/
  1261. X/* 1.4:  Use of short wherever possible. Portability        */
  1262. X/*     improvements, echo bug, fix for signed character    */
  1263. X/*     (for 8-bit ASCII):                900114    */
  1264. X/* 1.3:     MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  1265. X/* 1.2:     Max limits of by 1. Block nest error in function    */
  1266. X/*     backchar(). Fixed thanks to S. Creps:        881002    */
  1267. X/* 1.0:     Release:                    870515    */
  1268. X/****************************************************************/
  1269. X
  1270. X#include <curses.h>
  1271. X#include <curspriv.h>
  1272. X
  1273. Xstatic    char    *backchar();
  1274. X
  1275. Xchar _curses_strget_rcsid[] = "@(#)strget.c     v.1.4  - 900114";
  1276. X
  1277. Xstatic    bool     oldecho;
  1278. Xstatic    bool     oldcbreak;
  1279. Xstatic  bool     oldnodelay;
  1280. Xstatic    char    *strbeg;
  1281. Xstatic    WINDOW  *w;
  1282. Xstatic    short     xbeg;
  1283. X
  1284. X/****************************************************************/
  1285. X/* Wgetstr(win,str) reads in a string (terminated by \n or \r)    */
  1286. X/* to the buffer pointed to by 'str', and displays the input    */
  1287. X/* in window 'win'. The user's erase and kill characters are    */
  1288. X/* active.                            */
  1289. X/****************************************************************/
  1290. X
  1291. Xint wgetstr(win,str)
  1292. X  WINDOW    *win; 
  1293. X  char        *str;
  1294. X  {
  1295. X  w          = win;
  1296. X  strbeg      = str;        /* keep start for backspacing */
  1297. X  oldcbreak       = _cursvar.cbreak;    /* remember states */
  1298. X  oldecho         = _cursvar.echo;
  1299. X  oldnodelay      = w->_nodelay;
  1300. X  _cursvar.echo   = FALSE;        /* we do echo ourselves */
  1301. X  _cursvar.cbreak = TRUE;        /* no wait for chars */
  1302. X  w->_nodelay   = FALSE;        /* don't return 'NOCHARS' */
  1303. X  xbeg = w->_curx;            /* remember screen start x-position */
  1304. X
  1305. X  wrefresh(w);                /* sets cursor at right place */
  1306. X  while ((*str = (char) getch()) != '\n')
  1307. X    {
  1308. X    if (*str == '\r')
  1309. X      break;
  1310. X    if (*str == _DCCHAR)
  1311. X      {
  1312. X      if (str > strbeg)
  1313. X    str = backchar(str);
  1314. X      } /* if */
  1315. X    else
  1316. X      if (*str == _DLCHAR)
  1317. X    while (str > strbeg)
  1318. X      str = backchar(str);
  1319. X      else
  1320. X    {
  1321. X        if (oldecho)            /* check if echo */
  1322. X          {
  1323. X      waddch(w,*str++);
  1324. X      wrefresh(w);
  1325. X          }
  1326. X    else
  1327. X      str++;
  1328. X    } /* else */
  1329. X      } /* while */
  1330. X
  1331. X  *str = '\0';
  1332. X  _cursvar.echo   = oldecho;
  1333. X  _cursvar.cbreak = oldcbreak;
  1334. X  win->_nodelay   = oldnodelay;
  1335. X  return(OK);
  1336. X  } /* wgetstr */
  1337. X
  1338. X/****************************************************************/
  1339. X/* Getstr(str) reads in a string (terminated by \n or \r) to    */
  1340. X/* the buffer pointed to by 'str', and displays the input in    */
  1341. X/* stdscr. The user's erase and kill characters are active.    */
  1342. X/****************************************************************/
  1343. X
  1344. Xint getstr(str)
  1345. X  char *str;
  1346. X  {
  1347. X  return(wgetstr(stdscr,str));
  1348. X  } /* getstr */
  1349. X
  1350. X/****************************************************************/
  1351. X/* Mvgetstr(y,x,str) moves the stdscr cursor to a new position,    */
  1352. X/* then reads in a string (terminated by \n or \r) to the buf-    */
  1353. X/* fer pointed to by 'str', and displays the input in stdscr.    */
  1354. X/* The user's erase and kill characters are active.        */
  1355. X/****************************************************************/
  1356. X
  1357. Xint mvgetstr(y,x,str)
  1358. X  int y;
  1359. X  int x;
  1360. X  char *str;
  1361. X  {
  1362. X  if (wmove(stdscr,y,x) == ERR)
  1363. X    return(ERR);
  1364. X  return(wgetstr(stdscr,str));
  1365. X  } /* mvgetstr */
  1366. X
  1367. X/****************************************************************/
  1368. X/* Mvwgetstr(win,y,x,str) moves the 'win' cursor to a new    */
  1369. X/* position, then reads in a string (terminated by \n or \r)    */
  1370. X/* to the buffer pointed to by 'str', and displays the input in    */
  1371. X/* stdscr. The user's erase and kill characters are active.    */
  1372. X/****************************************************************/
  1373. X
  1374. Xint mvwgetstr(win,y,x,str)
  1375. X  WINDOW *win;
  1376. X  int      y;
  1377. X  int      x;
  1378. X  char     *str;
  1379. X  {
  1380. X  if (wmove(win,y,x) == ERR)
  1381. X    return(ERR);
  1382. X  return(wgetstr(win,str));
  1383. X  } /* mvwgetstr */
  1384. X
  1385. X/****************************************************************/
  1386. X/* Backchar() does a character delete with screen erase, even    */
  1387. X/* up to previous lines. It will not back-scroll if the begi-    */
  1388. X/* ning of the string has scrolled off the window. Steps back    */
  1389. X/* pointer 's', and returns the new value.            */
  1390. X/****************************************************************/
  1391. X
  1392. Xstatic char *backchar(s)
  1393. X  char      *s;
  1394. X  {
  1395. X  static short nbs;
  1396. X  static short x;
  1397. X  static char *p;
  1398. X  static short ts;
  1399. X
  1400. X  x =  xbeg;
  1401. X  ts =  w->_tabsize;
  1402. X
  1403. X  s--;                        /* step back string */
  1404. X  nbs = 1;                    /* step at least one pos */
  1405. X  if (((*s & 0xe0) == 0) || (*s == 0x7f))    /* ctrl-char has size 2 */
  1406. X    nbs++;
  1407. X  if (*s == '\t')                /* tabs are very special */
  1408. X    {
  1409. X    for (p = strbeg; p < s ;p++)        /* find x-pos of last char */
  1410. X      {
  1411. X      if (*p == '\t')                /* go to next tab */
  1412. X    x = ((x/ts)+1) * ts;
  1413. X      else
  1414. X    {
  1415. X    if (((*p & 0xe0) == 0) || (*p == 0x7f))    /* control character */
  1416. X      x += 2;
  1417. X    else                    /* normal char */
  1418. X      x++;
  1419. X    } /* else */
  1420. X      if (x >= w->_maxx)            /* go to next line? */
  1421. X    x = 0;
  1422. X      } /* for */
  1423. X    if (!(w->_curx))                /* if step-over newline */
  1424. X      nbs = w->_maxx - x;
  1425. X    else                    /* in-line tab */
  1426. X      nbs = w->_curx - x;            /* positions to erase */
  1427. X    } /* if */
  1428. X
  1429. X  if ((int) oldecho)                /* check if echo */
  1430. X    {
  1431. X    while(nbs--)                /* do so many */
  1432. X      {
  1433. X      if (w->_curx > 0)                /* if not at line beginning */
  1434. X        waddstr(w,"\b \b");
  1435. X      else
  1436. X        if (w->_cury)                /* if not on top line */
  1437. X      {
  1438. X        mvwaddch(w,w->_cury-1,w->_maxx -1,' ');/* put space at line end */
  1439. X      wmove(w,w->_cury-1,w->_maxx - 1);    /* and go there again */
  1440. X        } /* else */
  1441. X      } /* while */
  1442. X    wrefresh(w);                /* redraw screen */
  1443. X    }
  1444. X  *(s+1) = '\0';                /* make string terminated */
  1445. X  return(s);
  1446. X  } /* backchar */
  1447. END_OF_strget.c
  1448. if test 6043 -ne `wc -c <strget.c`; then
  1449.     echo \"strget.c\" unpacked with wrong size!
  1450. fi
  1451. # end of overwriting check
  1452. fi
  1453. echo End of archive 3 \(of 7\).
  1454. cp /dev/null archdone.3
  1455. MISSING=""
  1456. for I in 1 2 3 4 5 6 7 ; do
  1457.     if test ! -f archdone.${I} ; then
  1458.     MISSING="${MISSING} ${I}"
  1459.     fi
  1460. done
  1461. if test "${MISSING}" = "" ; then
  1462.     echo You have unpacked all 7 archives.
  1463.     rm -f archdone.[1-9]
  1464. else
  1465.     echo You still need to unpack the following archives:
  1466.     echo "        " ${MISSING}
  1467. fi
  1468. ##  End of shell archive.
  1469. exit 0
  1470.  
  1471.